// 定义扩展函数
import 'dart:core';
import 'dart:ffi';
import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:my_flutter/main.dart';

extension _ObjExtension on Object {

  num p375(int a) => 3 * a;
  num p2(int a) => 3 * a;
}

extension NumExtension1 on num {
  num get p2 => this * 3;
}

extension NumExtension on num {
  double get p {
    final flutterView = WidgetsBinding.instance.platformDispatcher.views.first;
    final ratio = flutterView.display.devicePixelRatio;
    final designScreenWidth = 360;
    return this * flutterView.display.size.width / ratio / designScreenWidth;
  }
}
var sc = ScreenAdapter(designScreenWidth: 200.0);

class ScreenAdapter {
  num designScreenWidth;

  ScreenAdapter({required this.designScreenWidth});

  var screenWidth = 100.0;

  num px(num designWidgetWidth){
    return designWidgetWidth / designScreenWidth * screenWidth;
  }
}
